package com.cys.dm.controller;

import com.cys.dm.entity.scheduler.DmScheduler;
import com.cys.dm.rest.service.DmItemService;
import com.cys.dm.vo.CommonResponse;
import com.cys.dm.vo.VoUtil;
import com.cys.dm.vo.dmitem.DmItem2Response;
import com.cys.dm.vo.dmitem.DmItemIndexSecondLevelVo;
import com.cys.dm.vo.dmitem.DmItemPriceVo;
import com.cys.dm.vo.dmitem.SeniorityResponse;
import com.cys.dm.vo.itemlist.DmMultipleItemVo;
import com.cys.dm.vo.itemlist.QueryItemList;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
public class DmItemController {
    @Resource
    private DmItemService dmItemService;

    @PostMapping(path = "/recommend")
    public CommonResponse<List<DmItem2Response>> recommend(){
        return dmItemService.todayRecommend();
    }

    @PostMapping(path = "/sell")
    public CommonResponse<List<DmItem2Response>> sell(){
        return dmItemService.queryToSaleItem();
    }

    @PostMapping(path = "/seniority")
    public CommonResponse<List<SeniorityResponse>> seniority(@RequestBody Map<String,Long> map){
        return dmItemService.postIndexSeniority(map.get("itemTypeId"));
    }

    /**
     * 根据日期查询商品
     */

    /**
     * 根据商品ID查询排期
     * @param map
     * @return
     */
    @PostMapping(path = {"getTimePlan"})
    public CommonResponse<List<DmScheduler>> getTimePlan(@RequestBody Map<String, Long> map){
        List<DmScheduler> dmSchedulerList = dmItemService.getTimePlan(map.get("itemId"));
        return VoUtil.returnSuccess("查询排期成功!",dmSchedulerList);
    }

    /**
     * 根据排期ID查询排期价格
     * @param map
     * @return
     */
    @PostMapping(path = {"getPrice"})
    public CommonResponse<List<DmItemPriceVo>> getPrice(@RequestBody Map<String, Long> map){
        return VoUtil.returnSuccess("查询排期价格成功！", dmItemService.getPrice(map.get("scheduleId")));
    }

    /**
     * 根据分类查询猜你喜欢轮播图
     * @param map
     * @return
     */
    @PostMapping(path = {"getCarouselData"})
    public CommonResponse<List<DmItemIndexSecondLevelVo>> getCarouselData(@RequestBody Map<String, Integer> map){
        return VoUtil.returnSuccess("查询猜你喜欢轮播成功！",dmItemService.getCarouselData(map));
    }


    /**
     * 亲子首页 猜你喜欢接口
     * @param map
     * @return
     */
    @PostMapping(path = {"getGuessYouLike"})
    public CommonResponse<List<QueryItemList>> getGuessYouLike(@RequestBody Map<String,Long> map){

        return VoUtil.returnSuccess("查询猜你喜欢商品成功！",dmItemService.getGuessYouLike(map));
    }

    /**
     * 精彩聚焦接口
     * @param map
     * @return
     */
    @PostMapping(path = {"getWonderfulData"})
    public CommonResponse<List<QueryItemList>> getWonderfulData(@RequestBody Map<String,Long> map){
        return VoUtil.returnSuccess("查询猜你喜欢商品成功！",dmItemService.getGuessYouLike(map));
    }

    /**
     * 根据年龄段查询节目
     * @param map
     * @return
     */
    @PostMapping(path = {"getParentChild"})
    public CommonResponse<List<QueryItemList>> getParentChild(@RequestBody Map<String,Integer> map){
        return VoUtil.returnSuccess("根据年龄段查询节目成功！",dmItemService.getParentChild(map));
    }

    @PostMapping(path = "/getCalendarData")
    public CommonResponse<List<DmMultipleItemVo>> getCalendarData(@RequestBody Map<String,String> param){
        return dmItemService.getCalendarData(param);
    }

}
